package com.cby.android.sample.fragments

import android.os.Bundle
import com.cby.android.library.base.BasePageStateFragment
import com.cby.android.sample.R
import com.cby.android.sample.adapter.ProjectArticleAdapter
import com.cby.android.sample.bean.wan.WanArticleBean
import com.cby.android.sample.model.ProjectListViewModel
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class ProjectArticlesFragment : BasePageStateFragment<ProjectListViewModel, WanArticleBean>() {

    private var cid: Int = 0

    companion object {

        private const val KEY_CID = "cid"

        fun newInstance(cid: Int): ProjectArticlesFragment {
            val fragment = ProjectArticlesFragment()
            var data = Bundle()
            data.putInt(KEY_CID, cid)
            fragment.arguments = data
            return fragment
        }
    }

    override fun parseArgs() {
        cid = arguments!!.getInt(KEY_CID)
    }

    override fun loadData() {
        viewModel!!.cid = cid
        super.loadData()
    }

    override fun getAdapter(): BaseQuickAdapter<WanArticleBean, BaseViewHolder> = ProjectArticleAdapter(
        R.layout.item_project_article)

    override fun addHeaderView(adapter: BaseQuickAdapter<WanArticleBean, BaseViewHolder>) {

    }
}